package com.thread.sync;

public class PrintRunnable implements Runnable {

//	private Object ojb = new Object();
	private String context;
	private int index;
	
	public PrintRunnable(String context) {
		this.context = context;
	}
	
	@Override
	public void run() {
		this.execute();
	}
	
	public String getContext() {
		return context;
	}

	//private synchronized void execute(){
	private void execute(){
		while (true){
			synchronized (this) {
				
				if ((index % 10) == 0)
				{
					System.out.println("done...");
					//break;
				}
				
				index++;
//				System.out.println(index + ":" + this.context);
				System.out.println(this.context);
				
			}
			try {
				Thread.sleep(100);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}

}
